<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>Linux查看网卡速度调整工作模式 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>Linux查看网卡速度调整工作模式</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;查看网卡速度有两个命令都可以查看：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mii-tool</div><div class="line">eth0: negotiated 1000baseT-FD flow-control, link ok</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这表示，eth0网卡的速度为1000M，并且是全双工工作模式，也可以使用</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">ethtool eth0</div><div class="line">Settings <span class="keyword">for</span> eth0:</div><div class="line"> Supported ports: [ TP ]</div><div class="line"> Supported link modes: 10baseT/Half 10baseT/Full</div><div class="line"> 100baseT/Half 100baseT/Full</div><div class="line"> 1000baseT/Full</div><div class="line"> Supports auto-negotiation: Yes</div><div class="line"> Advertised link modes: 10baseT/Half 10baseT/Full</div><div class="line"> 100baseT/Half 100baseT/Full</div><div class="line"> 1000baseT/Full</div><div class="line"> Advertised auto-negotiation: Yes</div><div class="line"> Speed: 1000Mb/s</div><div class="line"> Duplex: Full</div><div class="line"> Port: Twisted Pair</div><div class="line"> PHYAD: 0</div><div class="line"> Transceiver: internal</div><div class="line"> Auto-negotiation: on</div><div class="line"> Supports Wake-on: umbg</div><div class="line"> Wake-on: g</div><div class="line"> Current message level: 0x00000007 (7)</div><div class="line"> Link detected: yes</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Speed 后边的数值就是速度，Duplex后边就是工作不是，full表示全双工，如果是half则表示半双工模式；Auto-negotiation 后边表示是否自动协商</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;那么如何调整网卡的速度以及工作模式？</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改linux网卡的工作模式：</p>
<ul>
<li>ethtool –r ethX    重置ethX网口到自适应模式</li>
<li>ethtool –S ethX    查询ethX网口收发包统计</li>
<li>ethtool –s ethX [speed 10|100|1000]    设置网口速率10/100/1000M</li>
<li>[duplex half|full]                 设置网口半/全双工</li>
<li>[autoneg on|off]   设置网口是否自协商</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下面的命令会把eth0设置成全双工非自动协商工作模式，并且速度为100M</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ethtool -s eth0 duplex full autoneg off speed 100</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;设置网卡工作模式开机为全双工的方法：</p>
<ol>
<li>在/etc/sysconfig/network-script/ifcfg-ethX加入下面这句：</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ETHTOOL_OPTS=<span class="string">"speed 100 duplex full autoneg off"</span></div></pre></td></tr></table></figure>
<p>2.将上面的命令写入到/etc/rc.local里面。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ethtool -s eth0 duplex full autoneg off speed 100</div></pre></td></tr></table></figure>
	

	
		<span class="different-posts"><a href="/2017/10/12/1. Linux 基础/55. Linux查看网卡速度调整工作模式/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
